//
//  STSettingCollectionViewCell.swift
//  SeaTransportManage
//
//  Created by guopengwen on 2021/11/26.
//

import UIKit

class STSettingCollectionViewCell: UICollectionViewCell {
    
    class var identifier: String {
        get {
            return "STSettingCollectionViewCell"
        }
    }
    
    class func registerTo(_ collectionView: UICollectionView) {
        collectionView.register(STSettingCollectionViewCell.classForCoder(), forCellWithReuseIdentifier: STSettingCollectionViewCell.identifier)
    }
    
    class func reusableCell(_ collectionView: UICollectionView, indexPath: IndexPath) -> STSettingCollectionViewCell? {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: STSettingCollectionViewCell.identifier, for: indexPath) as? STSettingCollectionViewCell
        return cell
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor.white
        layer.cornerRadius = 12
        addSubview(descLabel)
        descLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(self)
            make.left.equalTo(16)
            make.height.equalTo(22)
        }
        
        addSubview(iconView)
        iconView.snp.makeConstraints { (make) in
            make.right.equalTo(-16)
            make.centerY.equalTo(descLabel)
            make.width.equalTo(20)
            make.height.equalTo(20)
        }
        
        addSubview(rightLabel)
        rightLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(descLabel)
            make.right.equalTo(-16)
            make.height.equalTo(22)
        }
    }
    
    public func updateCellData(title: String, _ index: Int) {
        descLabel.text = title
        if(index == 3) {
            iconView.isHidden = true
            rightLabel.isHidden = false
        } else {
            iconView.isHidden = false
            rightLabel.isHidden = true
        }
    }
    
    lazy var iconView: UIImageView = {
        let imgView = UIImageView.init(image: UIImage.init(named: "arrow-next"))
        return imgView
    }()
    
    
    lazy var descLabel: UILabel = {
        let lb = UILabel.init()
        lb.textAlignment = .center
        return lb
    }()
    
    lazy var rightLabel: UILabel = {
        let lb = UILabel.init()
        lb.textAlignment = .center
        lb.text = "V1.0.0"
        return lb
    }()
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
